// const Path = 'http://192.168.31.134:9001/'
// const Path = 'http://106.52.6.248:8080/'

const Path = 'http://106.54.205.166:9333/'


function getArraybuffer(url) {
	return (data) => {
		return uni.request({
			url: Path + url,
			method: "GET",
			data: data,
			responseType: 'arraybuffer'
		})
	}
}

function get(url) {
	return (data) => {
		return uni.request({
			url: Path + url,
			method: "GET",
			data: data
		})
	}
}

function post(url, data) {

	return uni.request({
		url: Path + url,
		method: "POST",
		header: {
			"Content-Type": "application/json",
			"DeviceInfo": getLanguage()

		},
		data: data
	})
}

function downloadFile(url, successCall) {
	return uni.downloadFile({
		url: Path + url,
		success: successCall,
		header: {
			"Content-Type": "application/json",
			"DeviceInfo": getLanguage()

		},
	})

}

function getLanguage() {
	return uni.getStorageSync('language');
}

function uploadFile(url, filePath, formData) {
	return uni.uploadFile({
		url: Path + url,
		filePath: filePath,
		name: 'file',
		formData: formData || {}
	});
}

function uploadFiles(filePath, formData) {
	return uni.uploadFile({
		url: Path + "uploadaccessory",
		filePath: filePath,
		name: 'file',
		formData: formData || {},
		success() {}
	});
}

export {
	getArraybuffer,
	Path,
	get,
	post,
	uploadFile,
	uploadFiles,
	downloadFile
}
